﻿using HighThroughput.ShareData;
using Ozone.Help;
using Ozone.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Ozone.ShareData
{
    /// <summary>
    /// 数据日志显示
    /// </summary>
    public class AppLogData
    {


        static public AppLogData g_AppLogData { set; get; }

        static public AppLogData Entity { get { return g_AppLogData; } }


        public object objAppLogLock { set; get; } = new object();


        //日志
        public List<AppLog> lstApplog
        { set; get; } = new List<AppLog>();

        public void addAppLog(int nMsgType, string content)
        {
            bool lockTaken = false;
            try
            {
                Monitor.TryEnter(objAppLogLock, 5000, ref lockTaken);
                if (lockTaken)
                {
                    lstApplog.Add(new AppLog(nMsgType, content));
                }
            }
            catch (Exception ex)
            {
               
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(objAppLogLock);
                }
            }
        }
    }
}
